using Prisa.Entities;

using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Prisa.DataAccess.Mapping
{
    public class DETALLE_CREDITOMap : EntityTypeConfiguration<DETALLE_CREDITO>
    {
        public DETALLE_CREDITOMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            // Table & Column Mappings
            this.ToTable("DETALLE_CREDITO");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.ProductoId).HasColumnName("ProductoId");
            this.Property(t => t.CreditoId).HasColumnName("CreditoId");
            this.Property(t => t.Cantidad).HasColumnName("Cantidad");
            this.Property(t => t.Precio).HasColumnName("Precio");
            this.Property(t => t.Pagado).HasColumnName("Pagado");
            this.Property(t => t.PasadoVenta).HasColumnName("PasadoVenta");
            this.Property(t => t.FechaDetalleCredito).HasColumnName("Fecha");
            
            // Relationships
            this.HasRequired(t => t.CREDITO)
                .WithMany(t => t.DETALLE_CREDITO)
                .HasForeignKey(d => d.CreditoId);

            this.HasRequired(t => t.PRODUCTO)
                .WithMany(t => t.DETALLECREDITOs)
                .HasForeignKey(d => d.ProductoId);

            

        }
    }
}
